<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Article extends Front_Controller{	
	protected $assignData = array();
	function __construct(){
		parent::__construct();
		$this->id = $this->uri->segment(3,0);
		$this->type = $this->uri->segment(2,0);
		if(strtolower($this->type)!='content'){
			$category = $this->JayphaDB->getDB(0,1,'',$this->db_table_prefix.'category',array('id'=>$this->id),'',true);
			foreach($category as $item){
				if($item->attribute==0){
					$this->list_tpl = $item->tempList;
				}else if($item->attribute==1){
					$this->list_tpl = $item->tempIndex;
				}
				$this->content_tpl = $item->tempArticle;
			}
		}else{
			$article = $this->JayphaDB->getDB(0,1,'channelId',$this->db_table_prefix.'archives',array('disabled'=>0,'ismake'=>1,'id'=>$this->id),'',true);
			if(count($article)>0){
				$category = $this->JayphaDB->getDB(0,1,'',$this->db_table_prefix.'category',array('id'=>$article[0]->channelId),'',true);
					foreach($category as $item){
						if($item->attribute==0){
							$this->list_tpl = $item->tempList;
						}else if($item->attribute==1){
							$this->list_tpl = $item->tempIndex;
						}
						$this->content_tpl = $item->tempArticle;
					}
			}
		}
	}
	
	function index(){
		if(isset($this->list_tpl)){	
			$this->display_cache($this->list_tpl,null,0,'article_list_'.$this->id.'_');
		}
	}
	
	function cate(){
		if(isset($this->list_tpl)){
			$this->display_cache($this->list_tpl,null,0,'article_list_'.$this->id.'_');
		}
	}
	
	//内容详细页面
	function content(){
		$this->load->view('article/content', $this->assignData);
		return;
	}

	public function dictionary() {
		$this->load->view('article/dictionary', $this->assignData);
		return;
	}

	public function calc() {
		$this->load->view('article/calc', $this->assignData);
		return;
	}

	//单页详细页面
	function single(){
		$this->load->view('article/single', $this->assignData);
		return;
	}
}